from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from news import models,newsser
# Create your views here.

class Newslist(APIView):
  def get(self,request):
    news = models.News.objects.filter(is_delete=False)
    ser = newsser.NewsSer(news,many=True)
    return Response(ser.data)

class Newsdetail(APIView):
  def get(self,request):
    news = models.News.objects.filter(is_delete=False,id=request.query_params.get('pk')).first()
    ser = newsser.NewsSer(news)
    return Response(ser.data)
